<?php

namespace app\api\controller;

use app\common\controller\Frontend;
use app\common\model\RecruitApply;

/**
 * 招聘
 */
class Recruit extends Frontend
{
    protected array $noNeedLogin = ['*'];

    /**
     * 招聘岗位
     * @return void
     * @throws \think\db\exception\DbException
     */
    public function lst(): void
    {
        $recruitModel = new \app\common\model\Recruit();
        $res = $recruitModel
            ->where("status", 1)
            ->order("weigh", "desc")
            ->order("release_time", "desc")
            ->paginate();
        $this->success("招聘岗位", $res);
    }


    /**
     * 岗位申请
     * @return void
     */
    public function apply(): void
    {
        $params = $this->request->post(['name', 'phone', 'recruit_id', 'file']);
        $params['apply_time'] = time();
        $recruitApplyModel = new RecruitApply();
        $res = $recruitApplyModel->save($params);
        $this->success("岗位申请", $res);
    }

}